<?php

class News_Page_Main_Article_View_Exception extends News_Page_Main_Article_Exception {}
class News_Page_Main_Article_View_Invalid_Exception extends News_Page_Main_Article_View_Exception {}

class News_Page_Main_Article_View extends News_Page_Main_Article {

	protected function URL($array = array()){
		return parent::URL(array_merge(
			array($this->article->id(), 'view'),
			$array
		));
	}

	public function rid($array = array()){
		return parent::rid(array_merge(
			array($this->article->id(), 'view'),
			$array
		));
	}

	public function __construct($args){
		parent::__construct($args);
		$this->article = News_Article::GetByID($args['id']);
	}

	public static function Load($args){
		return new News_Page_Main_Article_View($args);
	}

	public function run(){
		parent::run();
		$language = Authentication::getInstance()->user()->language();
			$this->date = date($language->translate(array('news','article','dateformat')),$this->article->date());
	}

	public function output($child = null){
		$template = Output::getInstance()->Template(array('news','page','article','view'));
		$template->title = $this->article->title();
		$template->body = $this->article->body();
		$template->date = $this->date;
		return parent::output($template);
	}

}
